#!/usr/bin/env bash

SOURCE_DIR=github.com/wxnacy/wgo
BIN=wgo
PWD=`pwd`
BIN_LINUX=`pwd`/bin/linux_amd64
BIN_DARWIN=`pwd`/bin/darwin_amd64

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install $SOURCE_DIR
# CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go install $SOURCE_DIR
# CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go install $SOURCE_DIR
go install $SOURCE_DIR
VER=`wgo version`

test -d bin || mkdir bin
test -d bin/linux_amd64 || mkdir bin/linux_amd64
# test -d bin/windows_amd64 || mkdir bin/windows_amd64
test -d bin/darwin_amd64 || mkdir bin/darwin_amd64

cp ${GOPATH}/bin/linux_amd64/$BIN bin/linux_amd64
# cp ${GOPATH}/bin/windows_amd64/$BIN.exe bin/windows_amd64
cp ${GOPATH}/bin/$BIN bin/darwin_amd64

cd $BIN_LINUX
zip $BIN-v${VER}-linux-amd64.zip $BIN

cd $BIN_DARWIN
zip $BIN-v${VER}-darwin-amd64.zip $BIN

echo 'Install Finshed'
